package com.lzq.leetcode.lanqiao;

import java.util.Scanner;

public class s89 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int N = scan.nextInt();
        int[] north = new int[N];
        int[] west = new int[N];


        for (int i = 0; i < N; i++) {
            north[i] = scan.nextInt();
        }

        int sum = 0;
        for (int i = 0; i < N; i++) {
            west[i] = scan.nextInt();
            sum += west[i];
        }

        int[] path = new int[N * N];
        boolean[][] map = new boolean[N][N];

        dfs(north, west, map, 0, 0, path, 0, N);

        for (int i = 0; i < sum; i++) {
            System.out.print(path[i] + " ");
        }
        System.out.println();


        scan.close();
    }

    private static boolean dfs(int[] north, int[] west, boolean[][] map, int x, int y, int[] path, int step, int N) {
        // 越界判断
        if (x < 0 || x >= N || y < 0 || y >= N || map[x][y]) return false;
        if (west[x] <= 0 || north[y] <= 0) return false;
        // 访问当前节点
        map[x][y] = true;
        path[step] = x * N + y;

        // 射箭

        --west[x];
        --north[y];

        // 判断是否结束
        if (x == N - 1 && y == N - 1) {
            for (int i = 0; i < N; i++) {
                if (north[i] != 0 || west[i] != 0) {
                    ++west[x];
                    ++north[y];
                    map[x][y] = false;
                    return false;
                }
            }
            return true;
        }

        // 移j动
        // 上
        if (dfs(north, west, map, x - 1, y, path, step + 1, N)) return true;
        // 右
        if (dfs(north, west, map, x, y + 1, path, step + 1, N)) return true;
        // 下
        if (dfs(north, west, map, x + 1, y, path, step + 1, N)) return true;
        // 左
        if (dfs(north, west, map, x, y - 1, path, step + 1, N)) return true;


        map[x][y] = false;
        ++west[x];
        ++north[y];

        return false;
    }
}
